package com.tianqi.familymap.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.orhanobut.logger.Logger;
import com.tianqi.familymap.R;
import com.tianqi.familymap.model.NodeModel;
import com.tianqi.familymap.utils.ContantUtils;

import java.util.List;

public class ImageSingleAdapter extends BaseQuickAdapter<String, BaseViewHolder> implements LoadMoreModule {
    private final Context mContext;

    public ImageSingleAdapter(List<String> data, Context mContext) {
        super(R.layout.item_image_single, data);
        this.mContext = mContext;
    }

    @Override
    protected void convert(BaseViewHolder holder, String bean) {
        //设置图片圆角角度
        RoundedCorners roundedCorners= new RoundedCorners(10);
        //通过RequestOptions扩展功能,override:采样率,因为ImageView就这么大,可以压缩图片,降低内存消耗
        RequestOptions options=RequestOptions.bitmapTransform(roundedCorners);
        Logger.i(bean);
        Glide.with(mContext).load(ContantUtils.BASE_URL + bean).apply(options).into((ImageView) holder.getView(R.id.iv_img_single));
    }
}
